<template>
  <div style="display: flex;height: 90%;">
    <div v-for="(shadow, i) in shadowGroup" :key="i">
      <div class="inline-flex" style="width: 100px;height: 100px;margin-bottom: 10px;" :style="{
        boxShadow: `var(${getCssVarName(shadow.type)})`,
      }" />
      <span p="y-4" class="demo-shadow-text" text="sm">
        {{ shadow.name }}
      </span>
      <code text="xs">
              {{ getCssVarName(shadow.type) }}
            </code>
    </div>
  </div>

  <div class="box">
    <el-scrollbar>
      <div class="item" v-for="item in list" :key="item.id">
        <el-popover @hide="hide" popper-class="my-pop" placement="top-start" :width="200" trigger="click">
          <div class="popover-box">
            <div class="left-pop" v-show="leftShow">
              <el-scrollbar height="100">
                <div class="select-item" v-for="k in list" :key="k.id">{{ k.name }}</div>
              </el-scrollbar>
            </div>
            <div class="left-pop empty" @click="hide" v-show="!leftShow"></div>
            <div class="right-pop">
              <div class="select-item">删除</div>
              <div class="select-item" @click="changeLeftShow">变更====</div>
            </div>
          </div>
          <template #reference>
            <el-button class="btn">Hover to activate</el-button>
          </template>
        </el-popover>
      </div>
    </el-scrollbar>
  </div>
</template>

<script lang="ts" setup>
import { ref, unref } from 'vue'

const shadowGroup = ref([
  {
    name: 'Basic Shadow',
    type: '',
  },
  {
    name: 'Light Shadow',
    type: 'light',
  },
  {
    name: 'Lighter Shadow',
    type: 'lighter',
  },
  {
    name: 'Dark Shadow',
    type: 'dark',
  },
])

const getCssVarName = (type: string) => {
  return `--el-box-shadow${type ? '-' : ''}${type}`
}
const list = Array.from({ length: 10 }).map((_, index) => {
  return {
    name: 'xxx' + index,
    id: index,
  }
})
const leftShow = ref(false)
const changeLeftShow = () => {
  leftShow.value = true
}
const hide = () => {
  leftShow.value = false
}
</script>

<style lang="scss" scoped>
.box {
  float: right;
  width: 30%;
  height: 100px;

  .item {
    height: 40px;
    width: 90%;
    background-color: skyblue;
    margin-bottom: 10px;
    display: flex;
    justify-content: flex-end;
  }

  .select-item {
    height: 30px;
    background-color: red;
    margin-bottom: 10px;
  }
}
</style>

<style lang="scss">
.my-pop {
  background: transparent !important;
  box-shadow: none !important;
  border: none !important;
  .popover-box {
    width: 100%;
    display: flex;

    .left-pop {
      width: 50%;
      border-right: 1px solid #000;
      background-color: #796868;

    }

    .right-pop {
      width: 50%;
      background-color: #524a4a;
    }
    .empty {
      background-color: transparent;
    }

    .select-item {
      height: 30px;
      background-color: #ddd;
      margin-bottom: 10px;
    }
  }
}
</style>
